exports.__esModule = true;

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

exports.default = class extends think.BaseController {
    /**
     * 查询行政区域
     */
    getAreaAction() {
        var _this = this;

        return _asyncToGenerator(function* () {
            const param = _this.post();
            try {
                const areaData = yield _this.service('cms/DeviceService').getAreaData(param.orgId);
                return _this.successJson(areaData);
            } catch (error) {
                return _this.errorJson(error);
            }
        })();
    }
    /**
     * 分页获取设备列表
     */
    getDeviceAction() {
        var _this2 = this;

        return _asyncToGenerator(function* () {
            const data = _this2.post();
            try {
                const deviceData = yield _this2.service('cms/DeviceService').getDevice(data);
                return _this2.successJson(deviceData);
            } catch (error) {
                return _this2.errorJson(error);
            }
        })();
    }

    /**
     * 获取全部设备列表
     */
    getAllDeviceAction() {
        var _this3 = this;

        return _asyncToGenerator(function* () {
            const data = _this3.post();
            try {
                const deviceData = yield _this3.service('cms/DeviceService').getAllDevice();
                return _this3.successJson(deviceData);
            } catch (error) {
                return _this3.errorJson(error);
            }
        })();
    }
    /**
     * 更改设备状态
     */
    changeDeviceEnableAction() {
        var _this4 = this;

        return _asyncToGenerator(function* () {
            const data = _this4.post();
            try {
                const isEnable = yield _this4.service('cms/DeviceService').changeDeviceEnable(data);
                return _this4.successJson(isEnable);
            } catch (error) {
                return _this4.errorJson(error);
            }
        })();
    }

    /**
     * 修改设备信息
     */
    changeDeviceInfoAction() {
        var _this5 = this;

        return _asyncToGenerator(function* () {
            const data = _this5.post();
            try {
                const deviceInfo = yield _this5.service('cms/DeviceService').changeDeviceInfo(data);
                return _this5.successJson(deviceInfo);
            } catch (error) {
                return _this5.errorJson(error);
            }
        })();
    }
    /**
     * 修改设备信息
     */
    deleteDeviceAction() {
        var _this6 = this;

        return _asyncToGenerator(function* () {
            const data = _this6.post();
            try {
                const deleteDevice = yield _this6.service('cms/DeviceService').deleteDevice(data);
                return _this6.successJson(deleteDevice);
            } catch (error) {
                return _this6.errorJson(error);
            }
        })();
    }
};